##############################################################################
# CMake
##############################################################################
cmake_minimum_required(VERSION 3.5)
project(testCuda)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11 -pthread")

set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
# find_package(OpenCV REQUIRED)

find_package(CUDA REQUIRED)
# set(CUDA_USE_STATIC_CUDA_RUNTIME  OFF)
find_package(OpenCV 2.4.13 REQUIRED )

find_package(GTest REQUIRED)
file(GLOB_RECURSE SOURCE_FILES src_std/*.cpp)
file(GLOB_RECURSE CU_FILES src/*.cu)
file(GLOB_RECURSE TEST_FILES test/*.cpp)
file(GLOB_RECURSE TESTLIB_FILES src_lib/*.cu)
file(GLOB_RECURSE TEST_TEGRA_FILES src_opencv4tegra/*.cu)

link_directories(/usr/local/lib)

include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}/include
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${GTEST_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}

  ${CMAKE_CURRENT_BINARY_DIR}/..
  ${CMAKE_CURRENT_BINARY_DIR}/../flow_std_plugin
  ${CMAKE_CURRENT_BINARY_DIR}/../flow_msg
  /usr/local/include/libgo
)


# cuda_add_executable(${PROJECT_NAME}
# 	${SOURCE_FILES}
# 	${CU_FILES}
# ) 

# target_link_libraries(${PROJECT_NAME}
# ${OpenCV_LIBS}


# )


# foreach(CU ${CU_FILES})
#     get_filename_component(prjName ${CU} NAME_WE)

#     cuda_add_executable(${prjName}
#           ${CU}
#     ) 
# endforeach()

# foreach(SOURCE ${SOURCE_FILES})
#     get_filename_component(prjName ${SOURCE} NAME_WE)

#     add_executable(${prjName}
#           ${SOURCE}
#     ) 
# endforeach()

foreach(TEST_TEGRA_FILE ${TEST_TEGRA_FILES})
    get_filename_component(prjName ${TEST_TEGRA_FILE} NAME_WE)

    cuda_add_executable(${prjName}
          ${TEST_TEGRA_FILE}
    ) 
    target_link_libraries(${prjName}
      ${OpenCV_LIBS}

      flow_msg
      flow_std_plugin
      libgo
    )

endforeach()


# foreach(TESTLIB_FILE ${TESTLIB_FILES})
#     CUDA_ADD_LIBRARY(prjName SHARED
#           ${TESTLIB_FILE}
#     ) 


#     target_link_libraries(${prjName}
#       ${CUDA_LIBRARIES}
#       )
# endforeach()



# foreach(TEST_FILE ${TEST_FILES})
#     get_filename_component(prjName ${TEST_FILE} NAME_WE)

#     add_executable(${prjName}
#           ${TEST_FILE}
#     ) 

#     target_link_libraries(${prjName}
#       sort_compare
#       ${GTEST_LIBRARIES} 
#       ${GTEST_MAIN_LIBRARIES}
#       )


# endforeach()



# cuda_add_executable(${PROJECT_NAME}
#   ${SOURCE_FILES}
# ) 
